﻿
//-------------------------------------------------------------------------------
// <copyright file="SwfObject.cs" company="GrannetDotNet Software">
//     Copyright © 2009 GrannetDotNet Software. All rights reserved.
// </copyright>
// <author>Grant Harmeyer</author>
//-------------------------------------------------------------------------------

namespace GrannetDotNet.Web.UI.WebControls
{
    /// <summary>
    /// Enumeration used to determine alignment for the Flash object
    /// </summary>
    public enum SwfAlign
    {
        /// <summary>
        /// Align the video to the left
        /// </summary>
        Left      = 1, // l
        /// <summary>
        /// Align the video to the right
        /// </summary>
        Right     = 2, // r
        /// <summary>
        /// Align the video to the top
        /// </summary>
        Top       = 4, // t
        /// <summary>
        /// Align the video to the bottom
        /// </summary>
        Bottom    = 8, // b        
    }

    /// <summary>
    /// Enumeration used to signify the networking access
    /// </summary>
    public enum SwfAllowNetworking
    { 
        /// <summary>
        /// All networking is allowed
        /// </summary>
        All      = 1, // all
        /// <summary>
        /// Only internal networking allowed
        /// </summary>
        Internal = 2, // internal
        /// <summary>
        /// No networking is allowed
        /// </summary>
        None     = 4, // none
    }

    /// <summary>
    /// Enumeration used to determine the quality with which to play the movie
    /// </summary>
    public enum SwfQuality
    {
        /// <summary>
        /// Use low video quality
        /// </summary>
        Low       = 1, // low
        /// <summary>
        /// Use high video quality
        /// </summary>
        High      = 2, // high
        /// <summary>
        /// Use auto-low video quality
        /// </summary>
        AutoLow   = 4, // autolow
        /// <summary>
        /// Use the best video quality
        /// </summary>
        Best      = 8, // best        
    }
    
    /// <summary>
    /// Enumeration used to determine alignment for the Flash object
    /// </summary>
    public enum SwfScaledAlignment
    {
        /// <summary>
        /// Align the video to the left
        /// </summary>
        Left        = 1,   // l
        /// <summary>
        /// Align the video to the right
        /// </summary>
        Right       = 2,   // r
        /// <summary>
        /// Align the video to the top
        /// </summary>
        Top         = 4,   // t
        /// <summary>
        /// Align the video to the bottom
        /// </summary>
        Bottom      = 8,   // b
        /// <summary>
        /// Align the video to the top-left
        /// </summary>
        TopLeft     = 16,   // tl
        /// <summary>
        /// Align the video to the top-right
        /// </summary>
        TopRight    = 32,  // tr
        /// <summary>
        /// Align the video to the bottom-left
        /// </summary>
        BottomLeft  = 64,  // bl
        /// <summary>
        /// Align the video to the bottom-right
        /// </summary>
        BottomRight = 128,  // br        
    }

    /// <summary>
    /// Enumeration used to determine the type of scale for the Flash object
    /// </summary>
    public enum SwfScale
    { 
        /// <summary>
        /// Use the default scale
        /// </summary>
        Default   = 1, // default
        /// <summary>
        /// Use no border on the scale
        /// </summary>
        NoBorder  = 2, // noborder
        /// <summary>
        /// Use an exact fit scale
        /// </summary>
        ExactFit  = 4, // exactfit
    }

    /// <summary>
    /// Enumeration used to determine if script access is allowed for the flash movie
    /// </summary>
    public enum SwfScriptAccess
    {
        /// <summary>
        /// Always allow script access
        /// </summary>
        Always     = 1, // always
        /// <summary>
        /// Never allow script access
        /// </summary>
        Never      = 2, // never
        /// <summary>
        /// Allows script access from the same domain
        /// </summary>
        SameDomain = 4, // samedomain
    }        

    /// <summary>
    /// Enumeration used to determine window mode for the Flash object
    /// </summary>
    public enum SwfWMode
    { 
        /// <summary>
        /// Use window mode
        /// </summary>
        Window      = 1, // window
        /// <summary>
        /// Use opaque mode
        /// </summary>
        Opaque      = 2, // opaque
        /// <summary>
        /// Use transparent mode
        /// </summary>
        Transparent = 4, // transparent
    }

    /// <summary>
    /// Class used to parse enumeration values
    /// </summary>
    internal static class SwfEnum
    {        
        /// <summary>
        /// Parses the enumeration value for rendering
        /// </summary>
        /// <param name="align">The alignment of video</param>
        /// <returns>A string representation of the enumeration value</returns>
        internal static string Parse(SwfAlign align)
        {
            string retVal = null;

            switch (align)
            {
                case SwfAlign.Left :

                    retVal = "l";

                    break;

                case SwfAlign.Right :

                    retVal = "r";

                    break;

                case SwfAlign.Top :

                    retVal = "t";

                    break;

                case SwfAlign.Bottom :

                    retVal = "b";

                    break;

                default:

                    retVal = string.Empty;

                    break;
            }

            return retVal;
        }

        /// <summary>
        /// Parses the enumeration value for rendering
        /// </summary>
        /// <param name="allowNetworking">The networking access for the movie</param>
        /// <returns>A string representation of the enumeration value</returns>
        internal static string Parse(SwfAllowNetworking allowNetworking)
        {
            string retVal = null;

            switch (allowNetworking)
            {
                case SwfAllowNetworking.All :

                    retVal = "all";

                    break;

                case SwfAllowNetworking.Internal :

                    retVal = "internal";

                    break;

                case SwfAllowNetworking.None :

                    retVal = "none";

                    break;

                default :

                    retVal = string.Empty;

                    break;
            }

            return retVal;
        }
        
        /// <summary>
        /// Parses the enumeration value for rendering
        /// </summary>
        /// <param name="quality">The quality for the video</param>
        /// <returns>A string representation of the enumeration value</returns>
        internal static string Parse(SwfQuality quality)
        {
            string retVal = null;

            switch (quality)
            { 
                case SwfQuality.AutoLow :

                    retVal = "autolow";

                    break;

                case SwfQuality.Best :

                    retVal = "best";

                    break;

                case SwfQuality.High :

                    retVal = "high";

                    break;

                case SwfQuality.Low :

                    retVal = "low";

                    break;

                default :

                    retVal = string.Empty;

                    break;
            }

            return retVal;
        }

        /// <summary>
        /// Parses the enumeration value for rendering
        /// </summary>
        /// <param name="alignment">The alignment value</param>
        /// <returns>A string representation of the enumeration value</returns>
        internal static string Parse(SwfScaledAlignment alignment)
        {
            string retVal = null;

            switch (alignment)
            {
                case SwfScaledAlignment.Left :

                    retVal = "l";

                    break;

                case SwfScaledAlignment.Right :

                    retVal = "r";

                    break;

                case SwfScaledAlignment.Top :
                    
                    retVal = "t";

                    break;

                case SwfScaledAlignment.Bottom :

                    retVal = "b";

                    break;

                case SwfScaledAlignment.TopLeft :

                    retVal = "tl";

                    break;

                case SwfScaledAlignment.TopRight :

                    retVal = "tr";

                    break;

                case SwfScaledAlignment.BottomLeft :

                    retVal = "bl";

                    break;

                case SwfScaledAlignment.BottomRight :

                    retVal = "br";

                    break;

                default :

                    retVal = string.Empty;

                    break;
            }

            return retVal;
        }

        /// <summary>
        /// Parses the enumeration value for rendering
        /// </summary>
        /// <param name="scale">The scale of the video</param>
        /// <returns>A string representation of the enumeration value</returns>
        internal static string Parse(SwfScale scale)
        {
            string retVal = null;

            switch (scale)
            {
                case SwfScale.Default :

                    retVal = "default";

                    break;

                case SwfScale.NoBorder :

                    retVal = "noborder";

                    break;

                case SwfScale.ExactFit :

                    retVal = "exactfit";

                    break;

                default :

                    retVal = string.Empty;

                    break;
            }

            return retVal;
        }

        /// <summary>
        /// Parses the enumeration for the script access value
        /// </summary>
        /// <param name="access">The enumertion value</param>
        /// <returns>A string representation of the value for rendering</returns>
        internal static string Parse(SwfScriptAccess access)
        {
            string retVal = null;

            switch (access)
            {
                case SwfScriptAccess.Always :

                    retVal = "always";

                    break;

                case SwfScriptAccess.Never :

                    retVal = "never";

                    break;

                case SwfScriptAccess.SameDomain:

                    retVal = "samedomain";

                    break;

                default:

                    break;
            }

            return retVal;
        }

        /// <summary>
        /// Parses the enumeration value for rendering
        /// </summary>
        /// <param name="mode">The mode value</param>
        /// <returns>A string representation of the enumeration value</returns>
        internal static string Parse(SwfWMode mode)
        {
            string retVal = null;

            switch (mode)
            {
                case SwfWMode.Window :

                    retVal = "window";

                    break;

                case SwfWMode.Opaque :

                    retVal = "opaque";

                    break;

                case SwfWMode.Transparent :

                    retVal = "transparent";

                    break;

                default :

                    retVal = string.Empty;

                    break;
            }

            return retVal;
        }
    }
}